home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / System / XFD / Developer / Sources / ASM / CATC.a < prev    next >
Encoding:
Text File  |  2001-09-16  |  3.6 KB  |  194 lines

  1. *******************************************************
  2. **             XFD external decruncher               **
  3. **          for Eldritch The Cat cruncher            **
  4. **             adapted by Wanted Team                **
  5. *******************************************************
  6.  
  7.     INCDIR    "dh2:Include/"
  8.     INCLUDE    "libraries/xfdmaster.i"
  9.  
  10. ; xfdForeman structure MUST be first thing in all external decrunchers
  11.  
  12. ForeMan        moveq    #-1,d0        ;security
  13.         rts
  14.         dc.l    XFDF_ID        ;id
  15.         dc.w    1        ;version
  16.         dc.w    0
  17.         dc.l    0,0        ;private
  18.         dc.l    S_CATC        ;first slave
  19.  
  20. **************************************************
  21.  
  22. ; xfdSlave structure: this one doesn't support data scanning
  23.  
  24. S_CATC        dc.l    0        ;no more slaves
  25.         dc.w    2        ;version
  26.         dc.w    39        ;master version
  27.         dc.l    N_CATC        ;name
  28.         dc.w    XFDPFF_DATA!XFDPFF_RECOGLEN!XFDPFF_USERTARGET
  29.         dc.w    0
  30.         dc.l    RB_CATC        ;recog buffer
  31.         dc.l    DB_CATC        ;decrunch buffer
  32.         dc.l    0        ;recog segment
  33.         dc.l    0        ;decrunch segment
  34.         dc.w    0,0
  35.         dc.l    12+2
  36.  
  37.         dc.b    "$VER: CATC v2.0 (21 Mar 2001) by Wanted Team",0
  38. N_CATC        dc.b    "Eldritch The Cat (CATC) data cruncher",0
  39.         even
  40.  
  41. ;-------------------------------------------------
  42.  
  43. ; Recog buffer function: receives buffer + length in a0/d0
  44.  
  45. RB_CATC
  46.     btst    #0,D0
  47.     bne.b    Exit
  48.     cmp.l    #"CATC",(A0)+
  49.     bne.b    Exit
  50.     tst.b    (A0)
  51.     bne.b    Exit
  52.     move.l    (A0),D1
  53.     subq.l    #4,A0
  54.     add.l    D0,A0
  55.     cmp.l    -(A0),D1
  56.     bne.b    Exit
  57.     move.l    D1,xfdrr_FinalTargetLen(A1)
  58.     move.l    D1,xfdrr_MinTargetLen(A1)
  59.     moveq    #1,D0
  60.     rts    
  61. Exit
  62.     moveq    #0,D0
  63.     rts
  64.  
  65. ;-------------------------------------------------
  66.  
  67. ; Decrunch buffer function: receives bufferinfo in a0
  68. ; This style requires xfdmaster.library V39
  69. DB_CATC    
  70.     movem.l    D2-D7/A2-A6,-(A7)
  71.     move.l    A0,A5
  72.     move.l    xfdbi_UserTargetBuf(A5),A1
  73.     move.l    xfdbi_UserTargetBufLen(A5),D1
  74.     move.l    xfdbi_SourceBuffer(A5),A0
  75.     move.l    xfdbi_SourceBufLen(A5),D0
  76.     add.l    D0,A0
  77.     lea    (A1,D1.L),A2
  78.     bsr.b    D_CATC
  79.     move.w    #XFDERR_CORRUPTEDDATA,xfdbi_Error(A5)
  80.     movem.l    (A7)+,D2-D7/A2-A6
  81.     rts
  82.  
  83. ;-------------------------------------------------
  84.  
  85. ; Decruncher from "Crime Does Not Pay" (c) Titus
  86.  
  87. ;    LINK.W    A6,#0
  88. ;    MOVEM.L    D0-D7/A0-A5,-(SP)
  89. ;    MOVEA.L    8(A6),A0
  90. ;    MOVEA.L    $10(A6),A1
  91. ;    MOVEA.L    12(A6),A2
  92. ;    BSR.S    lbC00AA7A
  93. ;    MOVEM.L    (SP)+,D0-D7/A0-A5
  94. ;    UNLK    A6
  95. ;    RTS
  96.  
  97. ; Input:
  98. ; A0 = start + length of file
  99. ; A1 = destination
  100. ; A2 = destination + depacked length
  101.  
  102. D_CATC
  103. lbC00AA7A    MOVE.L    -(A0),-(SP)
  104.     MOVE.L    -(A0),D5
  105.     MOVE.L    -(A0),D0
  106.     EOR.L    D0,D5
  107. lbC00AA82    LSR.L    #1,D0
  108.     BNE.S    lbC00AA8A
  109.     BSR.L    lbC00AB26
  110. lbC00AA8A    BCS.S    lbC00AAC8
  111.     MOVEQ    #8,D1
  112.     MOVEQ    #1,D3
  113.     LSR.L    #1,D0
  114.     BNE.S    lbC00AA98
  115.     BSR.L    lbC00AB26
  116. lbC00AA98    BCS.S    lbC00AAF4
  117.     MOVEQ    #3,D1
  118.     CLR.W    D4
  119. lbC00AA9E    BSR.L    lbC00AB32
  120.     MOVE.W    D2,D3
  121.     ADD.W    D4,D3
  122. lbC00AAA6    MOVEQ    #7,D1
  123. lbC00AAA8    LSR.L    #1,D0
  124.     BNE.S    lbC00AAB0
  125.     BSR.L    lbC00AB26
  126. lbC00AAB0    ROXL.L    #1,D2
  127.     DBRA    D1,lbC00AAA8
  128.     MOVE.B    D2,-(A2)
  129.     DBRA    D3,lbC00AAA6
  130.     BRA.L    lbC00AB02
  131.  
  132. lbC00AAC0    MOVEQ    #8,D1
  133.     MOVEQ    #8,D4
  134.     BRA.L    lbC00AA9E
  135.  
  136. lbC00AAC8    MOVEQ    #2,D1
  137.     BSR.L    lbC00AB32
  138.     CMP.B    #2,D2
  139.     BLT.S    lbC00AAEA
  140.     CMP.B    #3,D2
  141.     BEQ.S    lbC00AAC0
  142.     MOVEQ    #8,D1
  143.     BSR.L    lbC00AB32
  144.     MOVE.W    D2,D3
  145.     MOVE.W    #12,D1
  146.     BRA.L    lbC00AAF4
  147.  
  148. lbC00AAEA    MOVE.W    #9,D1
  149.     ADD.W    D2,D1
  150.     ADDQ.W    #2,D2
  151.     MOVE.W    D2,D3
  152. lbC00AAF4    BSR.L    lbC00AB32
  153. lbC00AAF8    SUBQ.W    #1,A2
  154.     MOVE.B    0(A2,D2.W),(A2)
  155.     DBRA    D3,lbC00AAF8
  156. lbC00AB02    CMPA.L    A2,A1
  157.     BLT.L    lbC00AA82
  158.     MOVE.L    (SP)+,D0
  159.     EOR.L    D0,D5
  160.     BNE.S    lbC00AB10
  161.  
  162.     moveq    #XFDERR_CORRUPTEDDATA,D0
  163.  
  164.     RTS
  165.  
  166. lbC00AB10
  167.  
  168.     moveq    #XFDERR_OK,D0
  169.  
  170. ;    MOVE.L    #$FFFFFFFF,D0
  171. ;lbC00AB16    MOVE.W    D0,$DFF180
  172. ;    SUBI.L    #1,D0
  173. ;    BNE.S    lbC00AB16
  174.     RTS
  175.  
  176. lbC00AB26    MOVE.L    -(A0),D0
  177.     EOR.L    D0,D5
  178.     MOVE.W    #$10,CCR
  179.     ROXR.L    #1,D0
  180.     RTS
  181.  
  182. lbC00AB32    SUBQ.W    #1,D1
  183.     CLR.W    D2
  184. lbC00AB36    LSR.L    #1,D0
  185.     BNE.S    lbC00AB44
  186.     MOVE.L    -(A0),D0
  187.     EOR.L    D0,D5
  188.     MOVE.W    #$10,CCR
  189.     ROXR.L    #1,D0
  190. lbC00AB44    ROXL.L    #1,D2
  191.     DBRA    D1,lbC00AB36
  192.     RTS
  193.  
  194.